package oop

import "fmt"

type GradeInfo struct {

	Name string

	Classes []Class
}


func NewGrade(n string) (grade GradeInfo) {
	grade = GradeInfo{Name:n}
	return
}

func (this *GradeInfo) AddClass(class Class) {
	this.Classes = append(this.Classes, class)
}

func (this *GradeInfo) PrintGrantInfo() {
	fmt.Println("年级名称",this.Name)
	fmt.Println("共有班级数量", len(this.Classes))
	fmt.Println("共有学生数量", this.countStudents())
}

func (this *GradeInfo) countStudents() (studentsNumber uint32) {

	for _,class  = range this.Classes {
		studentsNumber += uint32(len(class.Students))
	}
	return
}